home *** CD-ROM | disk | FTP | other *** search
/ Personal Computer World 2009 February / PCWFEB09.iso / Software / Linux / SLAX 6.0.8 / slax-6.0.8.iso / slax / base / 006-devel.lzm / usr / include / kdesu / su.h < prev   
Encoding:
C/C++ Source or Header  |  2006-10-01  |  1.5 KB  |  64 lines

  1. /* vi: ts=8 sts=4 sw=4
  2.  *
  3.  * $Id: su.h 570635 2006-08-07 13:48:26Z jriddell $
  4.  *
  5.  * This file is part of the KDE project, module kdesu.
  6.  * Copyright (C) 1999,2000 Geert Jansen <jansen@kde.org>
  7.  *
  8.  * This is free software; you can use this library under the GNU Library 
  9.  * General Public License, version 2. See the file "COPYING.LIB" for the 
  10.  * exact licensing terms.
  11.  */
  12.  
  13. #ifndef __SU_h_Included__
  14. #define __SU_h_Included__
  15.  
  16. #include <qcstring.h>
  17.  
  18. #include <kdelibs_export.h>
  19.  
  20. #include "stub.h"
  21.  
  22. /**
  23.  * Executes a command under elevated privileges, using su.
  24.  */
  25.  
  26. class KDESU_EXPORT SuProcess: public StubProcess
  27. {
  28. public:
  29.     SuProcess(const QCString &user=0, const QCString &command=0);
  30.     ~SuProcess();
  31.  
  32.     enum Errors { SuNotFound=1, SuNotAllowed, SuIncorrectPassword };
  33.  
  34.     /**
  35.      * Executes the command. This will wait for the command to finish.
  36.      */
  37.     enum checkMode { NoCheck=0, Install=1, NeedPassword=2 } ;
  38.     int exec(const char *password, int check=NoCheck);
  39.  
  40.     /** 
  41.      * Checks if the stub is installed and the password is correct.
  42.      * @return Zero if everything is correct, nonzero otherwise.
  43.      */
  44.     int checkInstall(const char *password);
  45.  
  46.     /**
  47.      * Checks if a password is needed.
  48.      */
  49.     int checkNeedPassword();
  50.  
  51. private:
  52.     enum SuErrors { error=-1, ok=0, killme=1, notauthorized=2 } ;
  53.     int ConverseSU(const char *password);
  54.  
  55. protected:
  56.     virtual void virtual_hook( int id, void* data );
  57. private:
  58.     class SuProcessPrivate;
  59.     SuProcessPrivate *d;
  60.     QString superUserCommand;
  61. };
  62.  
  63. #endif
  64.